$(function(){
    fixedRightBtn();
    $(".activity-left-opts span").click(function(e){
        e.stopPropagation();
        $(this).siblings("span").removeClass("selected");
        $(".activity-project").css("display", "none");
        $(this).addClass("selected");
        var index = $(this).index();
        $(".activity-content-"+index).css("display","block"); // 显示选项卡对应的内容
        oldOpen = null;
        isOpen = true;
        if($(".activity-content-"+index).find(".activity-pic").length === 0){

        }
        // activityInfo.selectIndex = index;

        ticket.selectIndex = index;

        if(index == 0){
            ticket.getJoinList();
        }else if(index == 1){
            ticket.getAllRefundList();
        }
        ticket.cancelSelect();

    });

    var anchorId = window.location.hash;
    if(anchorId == '#join'){
        $('.activity-simple').trigger('click');
    }
    if(anchorId == '#refund'){
        $('.activity-ticket').trigger('click');
    }

    ticketList.init();

    $('.t-search-3 input').focus(function () {
        $('.t-search-3').find('span').removeClass('orange');
    });
});

var ticketList = {
    //初始
    init:function () {
        setDateTime.setDate('#join_search_date_start');
        setDateTime.setDate('#join_search_date_end');
        setDateTime.setDate('#refund_search_date_start');
        setDateTime.setDate('#refund_search_date_end');
    },
    //重置搜索
    reSet:function () {
        $("select[name='activity_id']").val('');
        $("select[name='search_type']").val('phone');
        $('#join_search_date_start').val('');
        $('#join_search_date_end').val('');
        $('#refund_search_date_start').val('');
        $('#refund_search_date_end').val('');
        $('#join_search_value').val('');
        $('#refund_search_value').val('');
        $('.t-search-3').find('span').removeClass('orange')
    },
    //选择用户（全选）
    joinSelectedAll:function (val) {
        $("input[name='join_checkbox_select']").each(function() {
            this.checked = val;
        });
    },
    //选择用户（全选）
    refundSelectedAll:function (val) {
        $("input[name='refund_checkbox_select']").each(function() {
            this.checked = val;
        });
    },
    //近三天
    joinThreeDays:function (_this) {
        var nowDate = new Date();
        nowDate.toLocaleDateString();
        $('#join_search_date_end').val(nowDate.toLocaleDateString());
        var myDate = Date.parse(new Date());
        var sjc = myDate - (86400000 * 2);
        var aDate = new Date(sjc);
        $('#join_search_date_start').val(aDate.toLocaleDateString());
        $(_this).addClass('orange').siblings().removeClass('orange');
    },
    //近七天
    joinSevenDays:function (_this) {
        var nowDate = new Date();
        nowDate.toLocaleDateString();
        $('#join_search_date_end').val(nowDate.toLocaleDateString());
        var myDate = Date.parse(new Date());
        var sjc = myDate - (86400000 * 6);
        var aDate = new Date(sjc);
        $('#join_search_date_start').val(aDate.toLocaleDateString());
        $(_this).addClass('orange').siblings().removeClass('orange');
    },
    //近三天
    refundThreeDays:function (_this) {
        var nowDate = new Date();
        nowDate.toLocaleDateString();
        $('#refund_search_date_end').val(nowDate.toLocaleDateString());
        var myDate = Date.parse(new Date());
        var sjc = myDate - (86400000 * 2);
        var aDate = new Date(sjc);
        $('#refund_search_date_start').val(aDate.toLocaleDateString());
        $(_this).addClass('orange').siblings().removeClass('orange');
    },
    //近七天
    refundSevenDays:function (_this) {
        var nowDate = new Date();
        nowDate.toLocaleDateString();
        $('#refund_search_date_end').val(nowDate.toLocaleDateString());
        var myDate = Date.parse(new Date());
        var sjc = myDate - (86400000 * 6);
        var aDate = new Date(sjc);
        $('#refund_search_date_start').val(aDate.toLocaleDateString());
        $(_this).addClass('orange').siblings().removeClass('orange');
    }
};






